
{% import 'macros/render-type.njk' as macros with context %}

{#
  Renders a table of types based on a given channel filter. This expects a collection of 11ty pages
  passed in `all`, which point to the different names rendered on the site.
#}
{% macro renderReferenceTableForCollection(all, channel, platformAppsOnly = undefined) %}

<table class="reference fixed-table width-full">
  <thead>
    <tr>
      <th>Name</th>
      <th class="reference-collapse">Description</th>
    </tr>
  </thead>
  <tbody>

  {% for page in all %}
    {% set namespace = page.data.namespace %}
    {% set f = namespace.root._feature %}

    {% if (not channel or channel === f.channel) and (platformAppsOnly === f.platformAppsOnly) %}
      <tr>
        <td>
          {% set namespacePath = namespace.shortName | namespaceToPath %}
          <a class="link weight-medium" href="{{ namespacePath }}">{{ namespace.shortName }}</a>
        </td>
        <td class="reference-collapse type">
          {{ macros.renderAvailability(namespace.root, 'pad-bottom-300') }}
          {# We have a "_comment" extended field but we use shortText here in case it references peer files #}
          {{ namespace.root.comment.shortText | md | safe }}
        </td>
      </tr>
    {% endif %}
  {% endfor %}

  </tbody>
</table>

{% endmacro %}